package com.david.concurrent.join;

/**
 * @author wade
 * @version 1.0
 * @date 2021/7/19 18:22
 */
public class JoinInterruptDemo {
    public static void main(String[] args) throws InterruptedException {
        Thread threadOne = new Thread(() -> {
            System.out.println("threadOne begin run!");
            for (; ; ) {

            }
        });
        Thread mainThread = Thread.currentThread();
        Thread threadTwo = new Thread(() -> {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            mainThread.interrupt();
        });
        threadOne.start();
        threadTwo.start();

        threadOne.join();
    }
}
